package com.bdqn.rooms.util;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.bdqn.rooms.beans.Euser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class JedisTemlateUtil {
    public RedisTemplate getRedisTemplate() {
        return redisTemplate;
    }

    public void setRedisTemplate(RedisTemplate redisTemplate) {
        this.redisTemplate = redisTemplate;
    }

    @Autowired
   private RedisTemplate redisTemplate;


    /**
     * 判断key值是否在redis存在
     * @param keys
     * @return
     */
    public boolean KeyExists(String keys){

        return redisTemplate.hasKey(keys);
    }

    /**
     * 存入redis
     * @param object
     * @param name
     */
    public void DepositIn(Object object,String name){
        String str =  JSON.toJSONString(object);

        redisTemplate.boundValueOps(name).set(str);
    }

    /**
     * 取出
     * @param name
     * @return
     */
    public String takeOut(String name){

        String a = (String) redisTemplate.boundValueOps(name).get();

        return a;
    }



}
